<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>登录统计</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/Top.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/buttons.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/util/jquery.cookie.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/YMLib.js"></script>
    <style type="text/css">
        TD {font-size: 12px;margin:0px;padding:0px;}
        a{text-decoration:none;}
        .abgc_td td{padding-right:6px;}
    </style>
</head>
<body>
    <table align="left" width="99%"
           cellpadding="0" cellspacing="0"
           border="0">
        <tr>
            <td align="left" style="padding-left:10px;padding-top: 10px;">
                <fieldset style="width:100%;text-align:left;vertical-align:middle;border:1px solid #cde0f3;">
                    <legend style="padding: 0 0 0 0; font-weight: bold; color: Gray; font-size: 12px;">
                    </legend>
                    <div>
                        <table style=" margin:7px; vertical-align:middle;" cellspacing="0" class="abgc_td" >
                            <tr height="32">
                                <td align="right">管养单位：</td>
                                <td>
                                    <select id="gydw" style="width:220px"></select>
                                </td>
                                <td align="right">开始日期：</td>
                                <td><input name="startTime" type="text" id="startTime" style="width: 90px;"></td>
                                <td align="right">截止日期：</td>
                                <td><input name="endTime" type="text" id="endTime" style="width: 90px;"></td>
                                <td>
                                    <a id='mybuttion1' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:loadData()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">查询</a>
                                    <a id='mybuttion2' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:exportData()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">导&nbsp;&nbsp;出</a>
                                </td>
                            </tr>
                        </table>
                    </div>
                </fieldset>
            </td>
        </tr>
    </table>
    <div id="grid" width="100%"></div>
    <div id="dd"></div>
</body>
</html>
<script type="text/javascript">
    $(function () {
        loadUnit1("gydw",$.cookie("unit"));
        loadDate('startTime');
        loadDate('endTime');
        loadData();
    });

    function loadDate(id) {
        $("#" + id).datebox({
            closeText: '关闭',
            okText: '确定',
            formatter: function (date) {
                var y = date.getFullYear();
                var m = date.getMonth()+1;
                var d = date.getDate();
                if (m < 10) {
                    m = "0" + m;
                }
                if (d < 10) {
                    d = "0" + d;
                }
                return y + '-' + m + '-' + d;
            }
        });
    }

    function exportData() {
        var gydwdm = $("#gydw").combotree("getValues");
        if (gydwdm.length == 0) {
            gydwstr = $.cookie("unit2");
        } else if (gydwdm.length == 1) {
            if (gydwdm[0].substr(gydwdm[0].length-2,gydwdm[0].length)=="00") {
                gydwdm[0] = gydwdm[0].substr(0,gydwdm[0].length-2);
            }
            if (gydwdm[0].substr(gydwdm[0].length-2,gydwdm[0].length)=="00") {
                gydwdm[0] = gydwdm[0].substr(0,gydwdm[0].length-2);
            }
            gydwstr = gydwdm[0] ;
        } else {
            gydwstr = gydwdm.join(',');
        }

        var params = "gydwdm="+gydwstr+
            "&startTime="+$("#startTime").datebox("getValue")+
            "&endTime="+$("#endTime").datebox("getValue");
        window.location.href = "/jxcsxm/operate/exportLoginNum.do?"+params;
    }

    function loadData() {
        var gydwdm = $("#gydw").combotree("getValues");
        if (gydwdm.length == 0) {
            gydwstr = $.cookie("unit2");
        } else if (gydwdm.length == 1) {
            if (gydwdm[0].substr(gydwdm[0].length-2,gydwdm[0].length)=="00") {
                gydwdm[0] = gydwdm[0].substr(0,gydwdm[0].length-2);
            }
            if (gydwdm[0].substr(gydwdm[0].length-2,gydwdm[0].length)=="00") {
                gydwdm[0] = gydwdm[0].substr(0,gydwdm[0].length-2);
            }
            gydwstr = gydwdm[0] ;
        } else {
            gydwstr = gydwdm.join(',');
        }

        $("#grid").datagrid({
            url: '/jxcsxm/operate/queryLoginNum.do',
            queryParams: {
                gydwdm: gydwstr,
                startTime: $("#startTime").datebox("getValue"),
                endTime: $("#endTime").datebox("getValue")
            },
            singleSelect: false,
            striped: true,
            pagination: true,
            rownumbers: true,
            pageNumber: 1,
            pageList :  [50,100,150,200],
            pageSize: 50,
            nowrap: false,
            height: $(window).height()-100,
            width: $(window).width()-12,
            columns: [[
                {field:'opt_name',title:'单位/用户',width:240,align:'center'},
                {field:'loginNum',title:'登录次数',width:240,align:'center'},
                {field:'lasttime',title:'最近一次的登录时间',width:240,align:'center'},
            ]]
        });
    }
</script>
